/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
 var maxFrequency = function(nums, k) {
    nums.sort((a,b) => a-b)
    const n = nums.length
    let ans = 1, c = k
    for(let j = 1; j<n; j++){
        let temp = 1
        for(let i = j; i<n; i++){
            let dif = nums[i]-nums[i-1]
            c -= dif*(i-j+1)
            if(c < 0)
                break
            temp++
        }
        ans = Math.max(ans,temp)
        c = k
    }
    return ans
};